package com.milkshopbackend.milkshop.common;

import lombok.Data;

@Data
public class Result<T> {
    private Integer code;
    private String message;
    private T data;

    public static <T> Result<T> success()
    {
        return success(null);
    }
    public  static <T> Result<T> success(T data)
    {
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMessage("操作");
        result.setData(data);
        return result;
    }

    public static <T> Result<T> error()
    {
        return error(500, "操作失败");
    }

    public static <T> Result<T> error(Integer code, String message)
    {
        Result<T> result = new Result<>();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
}
